# Maintainer: Filipe Laíns (FFY00) <lains@archlinux.org>
# Maintainer: Daniel M. Capella <polyzen@archlinux.org>

pkgname=tree-sitter
pkgver=0.20.8
pkgrel=2
pkgdesc='An incremental parsing system for programming tools'
arch=('loong64' 'x86_64')
url='https://github.com/tree-sitter/tree-sitter'
license=('MIT')
provides=('libtree-sitter.so')
depends=('gcc-libs')
makedepends=('git' 'rust')
options=('!lto')
source=("$url/archive/v$pkgver/$pkgname-$pkgver.tar.gz")
sha512sums=('30fa3f97e1a24d469a7565dc91db629accdfbe081b43d951e9751059a0c7f763d727e95efce5806cd9b1689650773bee1106f4f91ba001da57df3b0d83dda967')

prepare() {
  cd $pkgname-$pkgver

  cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}

build() {
  cd $pkgname-$pkgver

  make

  cd cli

  cargo build --release --locked --offline --all-features
}

package() {
  cd $pkgname-$pkgver

  make DESTDIR="$pkgdir" PREFIX=/usr install

  install -Dm 755 target/release/$pkgname -t "$pkgdir"/usr/bin

  install -Dm 644 LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname
}

